package com.train.common.enums.impl;

import cn.hutool.core.util.ArrayUtil;
import com.train.common.enums.Enums;
import lombok.Getter;

/**
 * 业务类型枚举
 */
@Getter
public enum BusinessTypeEnums implements Enums {

    SEND_SMS(0, "发送短信"),
    REGISTER(1, "注册"),
    LOGIN(2, "登录"),

    VALIDATE_SMS(3, "验证短信"),
    ;

    private final Integer code;

    private final String message;

    BusinessTypeEnums(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }


    public static Enums getByCode(Integer code) {
        return ArrayUtil.firstMatch(enums -> enums.getCode().equals(code), values());
    }
}
